<?php
if ( !defined( "IN_OP" ) )
{
    exit( "You can't access this file directly..." );
}
if ( ( $curruser['acl'] < 255 || $curruser['acl'] == 255 && $curruser['prev_id'] != 0 ) && !SubAccountRight( $curruser, 1 ) )
{
    diemsg( "你不是管理者！" );
}
$showType = intval( getvar( "showType" ) );
$gameArr = array( 29 => "五不中", 39 => "六不中", 40 => "七不中", 41 => "八不中", 42 => "九不中", 43 => "十不中", 44 => "十一不中", 45 => "十二不中" );
$count_numArr = array( 29 => 5, 39 => 6, 40 => 7, 41 => 8, 42 => 9, 43 => 10, 44 => 11, 45 => 12 );
if ( !isset( $gameArr[$showType] ) )
{
    $showType = 29;
}
$ui = new UI();
$tpl = new Template2();
$conf = new Config();
$rs = getdb( "select * from lotto where open>='".date( "Y-m-d" )."' order by open" );
if ( $rs->eof )
{
    $ui->showErrorPage( "<p class=error>目前没有可以下注期数！</p>" );
    exit();
}
$open = $rs->f['open'];
$round = $rs->f['round'];
$lotto_id = $rs->f['id'];
$opnumber = $rs->f['n1'];
$rs->close();
$stopbet = $conf->get( "linebet" );
$startmode = "";
if ( date( "Y-m-d" ) < $open )
{
    $startmode = "disabled";
}
else if ( date( "Y-m-d" ) == $open )
{
    if ( $stopbet <= date( "Hi" ) && 0 < $opnumber )
    {
        $startmode = "disabled";
    }
    else if ( date( "Hi" ) <= $conf->get( "startbet" ) )
    {
        $startmode = "disabled";
    }
}
$t1 = strtotime( $open." ".$stopbet );
$dt = date( "Y-m-d" );
$tpl->Set( "timestap", $t1 - systime( ) );
$tpl->set( "phptime", systime( ) );
$tpl->set( "open", $open );
$tpl->set( "round", d3( $round ) );
$tpl->set( "dt", $dt );
$tpl->set( "lotto_id", $lotto_id );
$rs29 = getdb( "select sum(amount*upercent/100) from bet where lotto_id={$lotto_id} and bettype={$showType} and rame in (0,9)" );
$rss29 = getdb( "select sum(amount*percent255/100) from bet2 where lotto_id={$lotto_id} and bettype={$showType} and rame in (0,9)" );
$rsu29 = getdb( "select sum(amount) from bet8 where lotto_id={$lotto_id} and bettype={$showType} and rame in (0,9)" );
$rs = getdb( "select * from rate29 where lotto_id={$lotto_id} AND disk = 1 and bettype={$showType} LIMIT 1" );
if ( $rs->eof )
{
    $ui->showErrorPage( "<p class=error>系统目前维护中，请稍後！</p>" );
    exit();
}
else
{
    $rate29Arr = array();
    $i = 1;
    while ( $i < 50 )
    {
        $rate29Arr["r29_{$i}"] = floatval( $rs->f["r".d2( $i )] );
        ++$i;
    }
    $tpl->set( $rate29Arr );
    sort( $rate29Arr );
}
$rs->close();
$tpl->set( array( "r29_1_max" => sprintf( "%01.2f", $rate29Arr[0] ), "r29_1_min" => sprintf( "%01.2f", $rate29Arr[48] ) ) );
$tpl->set( "startnowdisable", $startmode );
$tpl->set( "money29", $rs29->f[0] + $rss29->f[0] - $rsu29->f[0] - 0 );
$prot_user = array();
$j = 0;
$i = 0;
while ( $i < 10 )
{
    $name = $conf->get( "port_systemuser_".$i );
    if ( $name != "" )
    {
        $prot_user[$j] = $name;
        ++$j;
    }
    ++$i;
}
$userrame1 = "&nbsp;<select name=account style='display:none'><option value='' selected> </option>";
$i = 0;
while ( $i < $j )
{
    $userrame1 .= "<option value='".$prot_user[$i]."'>".$prot_user[$i]."</option>";
    ++$i;
}
$userrame1 .= "</select>";
$tpl->set( "select_usr1", $userrame1 );
$tpl->load( "main", "unow29.htm" );
$tpl->set( "jslang", $g_conf['language'] );
$tpl->set( "showType", $showType );
include_once( "class_6h/class.menu.php" );
$fieldArr = array( "round" => $round, "open" => $open, "lotto_id" => $lotto_id, "split_id" => 1 );
$onlineMenu = new menu_6h( 2, $fieldArr );
$selectid = getvar( "select" ) == "" ? 0 : getvar( "select" );
$menuList = $onlineMenu->getMenu( $selectid );
$tpl->set( "menuList", $menuList );
$tpl->set( "selectid", $selectid );
unset( $onlineMenu );
$tdListMenu = "";
foreach ( $gameArr as $key => $val )
{
    $urlTemp = "op.php?op=admin&fp=unow29&showType={$key}&select={$selectid}";
    if ( $key == $showType )
    {
        $tdListMenu .= "<td class=td2>{$val}</td>";
    }
    else
    {
        $tdListMenu .= "<td bgColor=#e7ebef><a href=\"{$urlTemp}\">{$val}</a></td>";
    }
}
$tpl->set( "tdListMenu", $tdListMenu );
$tpl->set( "count_num", $count_numArr[$showType] );
$tpl->set( "cc", $gameArr[$showType] );
$tpl->show( "main" );
$ui->footer();
?>